package com.test.controller.api;

import com.test.entity.Book;
import com.test.service.BookService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
@RequestMapping("/api/admin")
public class AdminApiController {
    @Resource
    BookService bookService;
    @RequestMapping("/del-book")
    public String deleteBook(@RequestParam("id")int id){
        bookService.deleteBook(id);
        return "redirect:/page/admin/book";
    }
    @RequestMapping("/add-book")
    public String add_book(Book book){
        bookService.insertBook(book);
        return "redirect:/page/admin/book";
    }


}
